//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "fn_spectating.sqf"
#include <btc_macros.h>
TRACE_1("Start",_this);

BTC_r_s_list   = [];
BTC_r_s_target = objNull;
BTC_r_camera_nvg = false;
BTC_r_s_camera = "camera" camCreate (position BTC_r_base_spawn);
BTC_r_s_camera camSetTarget BTC_r_base_spawn;
BTC_r_s_camera cameraEffect ["internal", "BACK"];
BTC_r_s_camera camSetPos [(getpos BTC_r_base_spawn select 0) + 15,(getpos BTC_r_base_spawn select 1) + 15,10];
BTC_r_s_camera camCommit 0;
BTC_r_s_cam_view = [0,0.3,1.55];
player enableSimulation false;
disableSerialization;
_r_dlg = createDialog "BTC_spectating_dialog";
_ui = uiNamespace getVariable "BTC_r_dialog";
(_ui displayCtrl 122) ctrlShow false;
BTC_r_camera_EH_keydown = (findDisplay 46) displayAddEventHandler ["KeyDown", "_keydown = _this spawn BTCR_fnc_spectatingKeyDown"];
if ((BTC_spectating_view select 0) == 1) then {_lb = lbAdd [121,(BTC_s_mode_view select (BTC_spectating_view select 1))];} else {{_lb = lbAdd [121,_x];} foreach BTC_s_mode_view};
sleep 0.5;
call BTCR_fnc_spectatingLoad;
while {true} do
{
	if (!dialog) then {_r_dlg = createDialog "BTC_spectating_dialog";sleep 0.5;};
	call BTCR_fnc_spectatingLoad;
	player setpos [0,0,6000];
	player setVelocity [0,0,0];
	BTC_r_s_camera camSetTarget BTC_r_s_target;
	BTC_r_s_camera cameraEffect ["internal", "BACK"];
	BTC_r_s_camera attachTo [BTC_r_s_target,BTC_r_s_cam_view];
	BTC_r_s_camera camCommit 0;
	if (BTC_r_camera_nvg) then {camusenvg true;} else {camusenvg false;};
	//sleep 0.5;
};